#import "HHBaseTableViewCell.h"
#import <BCFoundation/UIImage+BCHelper.h>
#import <BCFoundation/UIColor+BCHelper.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
#import <Masonry/Masonry.h>
#pragma clang diagnostic pop

@interface HHBaseTableViewCell ()
@property (nonatomic, strong) UIImageView *sepaImgView;
@end

@implementation HHBaseTableViewCell

//MARK: - Life Cycle
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configureSubviews];
    }
    return self;
}
//MARK: - Override Methods
- (void)configureSubviews {
    if ([self customSeparator]) {
        
        self.sepaImgView = [[UIImageView alloc] initWithImage:[UIImage bc_imageWithColor:[UIColor bc_colorWithRGB:0xCCCCCC] withSize:CGSizeMake(CGRectGetWidth(self.bounds)-[self separatorLeftMargin], 0.5f)]];
        [self addSubview:self.sepaImgView];
        [_sepaImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo([self separatorLeftMargin]);
            make.bottom.right.mas_equalTo(self);
            make.height.mas_equalTo(0.5f);
        }];
    }
}

-(BOOL)customSeparator {
    return YES;
}
- (CGFloat)separatorLeftMargin {
    return 0.f;
}
-(void)highlight {
    
}
-(void)unhighlight {
    
}

//MARK: - Public Methods
- (void)setDisplaySeparator:(BOOL)displaySeparator {
    _displaySeparator = displaySeparator;
    if (!self.sepaImgView) {
        return;
    }
    self.sepaImgView.hidden = !displaySeparator;
}
-(UIViewController *)baseViewController {
    id responder = self;
    while (responder){
        if ([responder isKindOfClass:[UIViewController class]]){
            return responder;
        }
        responder = [responder nextResponder];
    }
    return nil;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self configureSubviews];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        [self highlight];
    }else{
        [self unhighlight];
    }
}
@end

